﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BarFaculdade.Module;
using BarFaculdade.Controller;

namespace BarFaculdade
{
   public partial class frmLogin : Form
   {
      public frmLogin()
      {
         InitializeComponent();

         btnCancel.DialogResult = DialogResult.Cancel;

         this.CancelButton = btnCancel;
      }

      private void btnLogar_Click(object sender, EventArgs e)
      {

         string user = string.Empty;
         string senha = string.Empty;

         UsuarioController usu = new UsuarioController();

         user = tbUsuario.Text;
         senha = tbSenha.Text;
         if (usu.conectar(user, senha))
         {
             btnLogar.DialogResult = DialogResult.OK;
             this.AcceptButton = btnLogar;
         }
         else
         {
             MessageBox.Show("Usuario/Senha Incorretos!", "Login Falhou!");
         }
      }

      private void frmLogin_KeyUp(object sender, KeyEventArgs e)
      {
          if (e.KeyCode == Keys.Enter)
          {
              btnLogar_Click(sender, e);
          }
      }
   }
}
